package com.coderman.common.starter.nacos.datajson.listener;

import com.coderman.common.starter.nacos.datajson.service.DataJsonHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;



/**
 * Description:
 * date: 2020/9/29 10:21 上午
 *
 * @author fanchunshuai
 * @version 1.0.0
 * @since JDK 1.8
 */
@Order(value = 1000)
@Component
public class NacosDataJsonConfigListener implements ApplicationListener<ApplicationStartedEvent> {
    private Logger logger = LoggerFactory.getLogger(NacosDataJsonConfigListener.class);

    @Autowired
    private DataJsonHelper dataJsonHelper;

    @Override
    public void onApplicationEvent(ApplicationStartedEvent event) {
        try {
            logger.info("应用启动成功,准备初始化业务配置数据:DataJsonConfig.......................");
            dataJsonHelper.init();
            logger.info("应用启动成功,初始化业务配置数据成功:DataJsonConfig.......................");

        } catch (Exception e) {
            logger.error("初始化远程配置失败",e);
        }


    }
}
